﻿using System.Linq;

namespace ProgressTracker.Domain.Translation
{
    public interface IDayMapper
    {
        Domain.Day Create(Data.Entities.Day day);
    }

    public class DayMapper : IDayMapper
    {
        ITaskForDayMapper _taskMapper;

        public DayMapper(ITaskForDayMapper taskMapper)
        {
            _taskMapper = taskMapper;
        }

        public Domain.Day Create(Data.Entities.Day day)
        {
            return new Day
            {
                Date = day.Date,
                Notes = day.Notes,
                TasksForDay = day.Tasks.Select(x => _taskMapper.Create(x, day))
            };
        }
    }
}
